/*
package com.wch.healthcareproducts.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.github.jdsjlzx.ItemDecoration.DividerDecoration;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.github.jdsjlzx.recyclerview.ProgressStyle;
import com.wch.healthcareproducts.R;
import com.wch.healthcareproducts.adapter.AddressManagerAdapter;
import com.wch.healthcareproducts.bean.AddressBean;
import com.wch.healthcareproducts.utils.DialogUtils;
import com.zhy.autolayout.AutoLinearLayout;

import org.greenrobot.eventbus.EventBus;
import org.litepal.crud.DataSupport;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

*/
/**
 * 管理收货地址界面
 *//*

public class AddressManagerActivity extends BaseActivity {

    @BindView(R.id.title_left_one_btn)
    ImageView titleLeftOneBtn;
    @BindView(R.id.tv_middle_title)
    TextView tvMiddleTitle;
    @BindView(R.id.ll_empty)
    AutoLinearLayout llEmpty;
    @BindView(R.id.title_right_one_btn)
    ImageView titleRightOneBtn;

    private LRecyclerView recyclerView;
    private LRecyclerViewAdapter lRecyclerViewAdapter;
    private AddressManagerAdapter adapter;
    private int TOTAL_COUNTER = 17;
    private static final int REQUEST_COUNT = 10;
    private static int mCurrentCounter = 0;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_address_manager);
        ButterKnife.bind(this);
        initView();
        initRecy();
    }

    private void initRecy() {
        recyclerView = (LRecyclerView) findViewById(R.id.addressmanager_recycler);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        adapter = new AddressManagerAdapter(AddressManagerActivity.this);
        lRecyclerViewAdapter = new LRecyclerViewAdapter(adapter);
        recyclerView.setAdapter(lRecyclerViewAdapter);

        DividerDecoration divider = new DividerDecoration.Builder(this)
                .setHeight(R.dimen.divider_height)
                .setPadding(R.dimen.divider_padding)
                .setColorResource(R.color.line_gray)
                .build();

        recyclerView.setHasFixedSize(true);
        recyclerView.addItemDecoration(divider);

        recyclerView.setRefreshProgressStyle(ProgressStyle.LineSpinFadeLoader);
        recyclerView.setArrowImageView(R.drawable.ic_pulltorefresh_arrow);
        recyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallSpinFadeLoader);

        //设置下拉刷新
        recyclerView.setPullRefreshEnabled(false);
        recyclerView.setLoadMoreEnabled(false);
        //设置头部加载颜色
        recyclerView.setHeaderViewColor(R.color.colorAccent, R.color.black, android.R.color.white);
        //设置底部加载颜色
        recyclerView.setFooterViewColor(R.color.colorAccent, R.color.black, android.R.color.white);
        //设置底部加载文字提示
        recyclerView.setFooterViewHint("拼命加载中", "已经全部为你呈现了", "网络不给力啊，点击再试一次吧");
        //初始化数据
        getInfo();

        //修改默认地址，点击选择框
        adapter.setOnDefaultClickListener(new AddressManagerAdapter.OnDefaultClickListener() {
            @Override
            public void onItemClick(View view, final int position) {
                AddressBean bean = DataSupport.order("aid asc").find(AddressBean.class).get(position);
                //修改了默认地址
//                adapter.setSelectId(bean.getAid());
                changeMoRen(position);
            }
        });

        //删除地址，点击删除按钮
        adapter.setOnItemWchClickListener(new AddressManagerAdapter.OnItemWchClickListener() {
            @Override
            public void onItemClick(View view, int position) {

                List<AddressBean> beanList = DataSupport.order("aid asc").find(AddressBean.class);
//                LogUtils.d(beanList.get(position).getAid());
                if (beanList.size() == 1) {
                    DataSupport.deleteAll(AddressBean.class);
                    recyclerView.setVisibility(View.GONE);
                    llEmpty.setVisibility(View.VISIBLE);
                } else {
                    DialogUtils.showProgressDlg(AddressManagerActivity.this, "删除中....");
                    AddressBean addressBean = beanList.get(position);
//                    DataSupport.delete(AddressBean.class, addressBean.getAid());
                    DialogUtils.stopProgressDlg();
                    //刷新
                    adapter.clear();
                    lRecyclerViewAdapter.notifyDataSetChanged();
                    adapter.addAll(DataSupport.order("aid asc").find(AddressBean.class));
                }

            }
        });

    }

    private List<AddressBean> lists;

    */
/**
     * 修改数据库中地址的位置
     * 交换位置的时候aid不变，只改变其他内容，从数据库中获取地址时，根据aid 升序获取集合，这样aid就一直
     * 保持不变
     *//*

    private void changeMoRen(int position) {
        DialogUtils.showProgressDlg(AddressManagerActivity.this, "正在设置....");
        lists = DataSupport.order("aid asc").find(AddressBean.class);
        //现将第一个地址换到中间对象
        AddressBean first = lists.get(0);
        AddressBean middlebean = new AddressBean();
//        middlebean.setConsignee_name(first.getConsignee_name());
//        middlebean.setConsignee_phone(first.getConsignee_phone());
//        middlebean.setConsignee_address(first.getConsignee_address());
//
//        //将当前选择的地址赋值给第一个地址
//        AddressBean selectBean = lists.get(position);
//        first.setConsignee_name(selectBean.getConsignee_name());
//        first.setConsignee_phone(selectBean.getConsignee_phone());
//        first.setConsignee_address(selectBean.getConsignee_address());
        first.save();
//
//        //将中间对象数据赋值给当前选择的地址
//        selectBean.setConsignee_name(middlebean.getConsignee_name());
//        selectBean.setConsignee_phone(middlebean.getConsignee_phone());
//        selectBean.setConsignee_address(middlebean.getConsignee_address());
//        selectBean.save();

        DialogUtils.stopProgressDlg();
        //刷新
        adapter.clear();
        lRecyclerViewAdapter.notifyDataSetChanged();
        adapter.addAll(DataSupport.order("aid asc").find(AddressBean.class));

        lists.clear();
    }

    private void getInfo() {
        List<AddressBean> lists = DataSupport.order("aid asc").find(AddressBean.class);
        if (lists.size() == 0) {
            recyclerView.setVisibility(View.GONE);
            llEmpty.setVisibility(View.VISIBLE);
        } else {
            recyclerView.setVisibility(View.VISIBLE);
            llEmpty.setVisibility(View.GONE);
            adapter.addAll(lists);
            mCurrentCounter = lists.size();
            recyclerView.refreshComplete(lists.size());
        }
    }


    private void initView() {
        titleLeftOneBtn.setVisibility(View.VISIBLE);
        tvMiddleTitle.setText("管理收货地址");
    }

    @OnClick(R.id.title_left_one_btn)
    public void onViewClicked() {
        finish();
        EventBus.getDefault().postSticky("11");
    }

    */
/**
     * 点击返回按钮或者回退图标时，通知地址列表刷新
     *//*

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        EventBus.getDefault().postSticky("11");
    }

    //-----------------------------------------------------
}
*/
